<template>
  <div class="block">
    {{this.msg}}
    <div v-if="activities.length > 0">
      <el-timeline>
        <el-timeline-item v-for="(activity, index) in activities" :key="index" :color="'#0bbd87'" :timestamp="activity.time">
          {{activity.status}}
        </el-timeline-item>
      </el-timeline>
    </div>
    <div v-else>未查询到物流信息</div>

  </div>
</template>

<script>
import { listLogisticsInfo } from "@/api/order/order.js";

export default {
  props: {
    logistics: { type: Object, default: "" },
  },
  data() {
    return {
      queryParams: {
        no: undefined,
        phone: undefined,
        type: undefined,
      },
      msg: '',
      activities: []
    };
  },
  mounted() {
    this.queryParams.no = this.logistics.trackingNumber;
    this.queryParams.phone = this.logistics.pickUpPhone;
    this.queryParams.type = this.logistics.trackingType;

    this.getList();
  },

  methods: {
    getList() {
      this.loading = true;
      listLogisticsInfo(this.queryParams).then((response) => {
        if (response.code == 200) {
          if (response.data.result.list && response.data.result.list.length) {
            this.activities = response.data.result.list;
            console.log(this.activities)
          } else {
            this.msg = response.data.msg;
          }
        }
        this.loading = false;
      });
    },
  },
};
</script>

